package com.eshop.modules.activity.rest;

import org.springframework.web.bind.annotation.DeleteMapping;
import com.eshop.modules.aop.ForbidSubmit;
import java.io.Serializable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import io.swagger.annotations.ApiOperation;
import com.eshop.logging.aop.log.Log;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.data.domain.Pageable;
import com.eshop.modules.activity.service.dto.StoreCouponIssueUserQueryCriteria;
import com.eshop.modules.activity.service.StoreCouponIssueUserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;

@Api(tags = { "商城:优惠券前台用户领取记录管理" })
@RestController
@RequestMapping({ "api" })
public class StoreCouponIssueUserController
{
    private final StoreCouponIssueUserService storeCouponIssueUserService;
    
    public StoreCouponIssueUserController(final StoreCouponIssueUserService storeCouponIssueUserService) {
        this.storeCouponIssueUserService = storeCouponIssueUserService;
    }
    
    @Log("查询")
    @ApiOperation("查询")
    @GetMapping({ "/yxStoreCouponIssueUser" })
    @PreAuthorize("hasAnyRole('admin','YXSTORECOUPONISSUEUSER_ALL','YXSTORECOUPONISSUEUSER_SELECT')")
    public ResponseEntity getYxStoreCouponIssueUsers(final StoreCouponIssueUserQueryCriteria criteria, final Pageable pageable) {
        return new ResponseEntity(this.storeCouponIssueUserService.queryAll(criteria, pageable), HttpStatus.OK);
    }
    
    @ForbidSubmit
    @Log("删除")
    @ApiOperation("删除")
    @DeleteMapping({ "/yxStoreCouponIssueUser/{id}" })
    @PreAuthorize("hasAnyRole('admin','YXSTORECOUPONISSUEUSER_ALL','YXSTORECOUPONISSUEUSER_DELETE')")
    public ResponseEntity delete(@PathVariable final Integer id) {
        this.storeCouponIssueUserService.removeById((Serializable)id);
        return new ResponseEntity(HttpStatus.OK);
    }
}
